
	Cricket.Controller = {
				Prefs: new _IG_Prefs(),
				AllTabs: ['live', 'results', 'fixtures'],
				CurrentTab: 'results',
				CurrentHeight: 'Min',
				NotificationClosed: false,
				init: function() {
					//set tab to land on
					Cricket.Controller.CurrentTab = Cricket.Controller.Prefs.getString('cricket_tab');
					//start tracking
					Cricket.Tracking.init();					
					//show loader
					Cricket.Data.fetchAndParse();
					//set live to update every 20 secs
					setInterval('Cricket.Data.updateLive()', Cricket.Live.UpdateInterval);
				},
				onResize: function() {
					//set the right classes for logo
					Cricket.Controller.setPageClases();
				},
				setPageClases: function() {
					var Case = 'wide'
					if(315 > document.body.clientWidth) {
						Case = 'none';
					}else if(350 > document.body.clientWidth) {
						Case = 'thin';
					} else if (405 > document.body.clientWidth) {
						Case = 'mid';
					} 
					if(_gel('page')) {
						switch(Case) {
							case 'none':
								_gel('page').className = 'min-size no-logo';
								break;
							case 'thin':
								_gel('page').className = 'min-size min-logo';
								break;
							case 'mid':
								_gel('page').className = 'half-logo';
								break;
							case 'wide':
							default:
								_gel('page').className = '';
								break;
						}
					}
				},
				toggleHeight: function() {
					if('Min' == Cricket.Controller.CurrentHeight) {
						//expand
						_gel('content-container').style.height='605px';
						_gel('expand').firstChild.className = 'showcollapse';
					 	var DivsToExpand = document.getElementsByClassName('collapsedContainerStyle');
	                    for (var i=0; i<DivsToExpand.length; i++) {
	                        DivsToExpand[i].className='expandedContainerStyle';
	                    }
						Cricket.Controller.CurrentHeight = 'Max';
					} else {
						//collapse
						_gel('content-container').style.height='272px';
						_gel('expand').firstChild.className = 'showexpand';
						var DivsToCollapse = document.getElementsByClassName('expandedContainerStyle');
	                    for (var i=0; i<DivsToCollapse.length; i++) {
	                        DivsToCollapse[i].className='collapsedContainerStyle';
	                    }
						Cricket.Controller.CurrentHeight = 'Min';
						
					}
					_IG_AdjustIFrameHeight();
				},
				activateTab: function(ForObject) {	
					Cricket.Tracking.track('/view/'+ForObject.TabId);
					//hide messages, loaders
					Cricket.Messages.clear();
					Cricket.Messages.hideLoader();				
					Cricket.Controller.hideCricBuzz();
					//all tabs hide
					for(var i = 0; i < Cricket.Controller.AllTabs.length; i++) {
						if(_gel(Cricket.Controller.AllTabs[i]) && _gel(Cricket.Controller.AllTabs[i]).firstChild.className.match('active')) {
							_gel(Cricket.Controller.AllTabs[i]).firstChild.className = _gel(Cricket.Controller.AllTabs[i]).firstChild.className.replace('active', '');
						} 
						if(_gel(Cricket.Controller.AllTabs[i]+'-container')) {
							_gel(Cricket.Controller.AllTabs[i]+'-container').style.display = 'none';
						}
					}
					//hide
					if(_gel(ForObject.TabId) && _gel(ForObject.TabId+'-container')) {
						_gel(ForObject.TabId).firstChild.className += ' active';
						Cricket.Controller.Prefs.set('cricket_tab', ForObject.TabId);
						Cricket.Controller.CurrentTab = ForObject.TabId;
						
						if(1 === ForObject.Data.Success) {
							if(true === ForObject.Reloaded) {
								Cricket.Util.drawFilters(ForObject);
								Cricket.Util.drawSearch(ForObject);
								
							}
							ForObject.Reloaded = false;
							_gel(ForObject.TabId+'-container').style.display = 'block';
						} else {
							Cricket.Messages.show(ForObject.Data.Message);
						}
					} 
					
				},
				getCurrentTab: function() {
					return Cricket.Controller.CurrentTab;
				},
				hideLiveNotification: function() {
					Cricket.Controller.NotificationClosed = true;
					_gel('results-live-notification').style.display = 'none';
				},
				showLiveNotification: function() {
					_gel('results-live-notification').style.display = 'block';
				},
				showCricBuzz: function() {
					_gel('cricBuzz').style.display = 'block';
				},
				hideCricBuzz: function() {
					_gel('cricBuzz').style.display = 'none';
				},
				updateCricBuzz: function(Url) {
					_gel('cricBuzz-link').href = Url;
					this.showCricBuzz();
				}
			}